#include "StartingMenu.h"
#include "MenuManager.h"
#include "PrintUtils.h"
#include "GameControls.h"

using namespace std;

StartingMenu::StartingMenu(MenuManager* const i_menuManager) 
	:Menu(i_menuManager), continue_game_(false) {}

void StartingMenu::Draw(Console& console) const {
	PrintTitle(console, " WELCOME TO ZALCETTO!");

	options_[0] = WriteString(console, 10, 10, string("Play a new game"));
	options_[1] = WriteString(console, 13, 10, string("Load saved game"));
	options_[2] = continue_game_ ? WriteString(console, 16, 10, string("Continue")) : Console::NO_ENTRY;
	options_[3] = WriteString(console, 19, 10, string("Exit"));
}

Menu* StartingMenu::Input(const Inputs& input) {
	for (const auto& i : input) {
		if (i.type_ == INPUT_KEY_PRESSED) {
			if (i.content_ == K_ESCAPE) {
				return 0;
			}
		}	
		else if (i.type_ == INPUT_MOUSE_LCLICK && i.content_ != Console::NO_ENTRY){
			if (i.content_ == options_[0]) {
				GetMM()->GetGameControls()->Restart();
				GetMM()->PushMenu(GetMM()->GetMainMenu());
			} else if (i.content_ == options_[1]) {
				GetMM()->PushMenu(GetMM()->GetLoadMenu());
			} else if (i.content_ == options_[2]) {
				GetMM()->PushMenu(GetMM()->GetMainMenu());
			}	else if (i.content_ == options_[3]) {
				return 0;
			}
		}
	}
	return GetMM()->GetCurrentMenu();
}

int type_;
int content_;
Position position_;
//bool StartingMenu::Input(const STL::string& i_input)
//{
//	bool goodInput = true;
//
//	int res = Utilities::StringToInt(i_input);
//
//	switch (res)
//	{
//	case 1:
//		GetMM()->GetGameControls()->Restart();
//		GetMM()->PushMenu(GetMM()->GetMainMenu());
//		break;
//
//	case 2:
//		GetMM()->PushMenu(GetMM()->GetLoadMenu());
//		break;
//
//	case 3:
//		if (m_continueGame)
//			GetMM()->PushMenu(GetMM()->GetMainMenu());
//		else
//			goodInput = false;
//		break;
//
//	case 0:
//		GetMM()->GetGameControls()->Quit();
//		break;
//
//	default:
//		goodInput = false;
//	}
//	return goodInput;
//}
//
